//package com.woniuxy.lab.woniu_lab.filter;
//
//
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//
//@Configuration
//public class WebFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
//        //在该方法完成对响应头的相关设置来完成跨域处理
//        HttpServletRequest req = (HttpServletRequest) request;
//        HttpServletResponse resp = (HttpServletResponse) response;
//        String method = req.getMethod();
//        //设置允许哪些源可以跨域访问
//        resp.setHeader("Access-Control-Allow-Origin","*");
//        //设置允许哪些请求方式可以跨域访问
//        resp.setHeader("Access-Control-Allow-Methods","*");
//        //设置允许哪些请求头信息可以跨域访问
//        resp.setHeader("Access-Control-Allow-Headers","*");
//        //设置跨域访问是否允许附带cookie信息
//        resp.setHeader("Access-Control-Allow-Credentials","true");
//        //预检请求通过之后，多长时间内再发跨域请求不再进行预检
//        resp.setHeader("Access-Control-Max-Age","3600");
//        chain.doFilter(req,resp);
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}